package com.gisocn.onemap.presenter;

import com.gisocn.onemap.base.BasePresenter;
import com.gisocn.onemap.utils.ExecutorsManager;
import com.gisocn.onemap.utils.PullHelper;
import com.gisocn.onemap.view.FilePackageView;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;

/* loaded from: classes2.dex */
public class FilePackagePresenter extends BasePresenter<FilePackageView> {
    HttpURLConnection conn;
    private URL url = null;

    public FilePackagePresenter(FilePackageView filePackageView) {
        attachView(filePackageView);
    }

    public void getFileCenter(final String str) {
        ExecutorsManager.getInstance().execute(new Runnable() { // from class: com.gisocn.onemap.presenter.FilePackagePresenter.1
            @Override // java.lang.Runnable
            public void run() {
                try {
                    FilePackagePresenter.this.url = new URL(str);
                    try {
                        FilePackagePresenter filePackagePresenter = FilePackagePresenter.this;
                        filePackagePresenter.conn = (HttpURLConnection) filePackagePresenter.url.openConnection();
                        InputStream inputStream = FilePackagePresenter.this.conn.getInputStream();
                        byte[] bArr = new byte[1024];
                        StringBuffer stringBuffer = new StringBuffer();
                        while (inputStream.read(bArr) != -1) {
                            stringBuffer.append(new String(bArr, Charset.forName("utf-8")));
                        }
                        FilePackagePresenter.this.conn.disconnect();
                        inputStream.close();
                        ((FilePackageView) FilePackagePresenter.this.mvpView).getFileCenter(PullHelper.getFileCenter(new ByteArrayInputStream(stringBuffer.toString().getBytes())));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } catch (MalformedURLException e2) {
                    e2.printStackTrace();
                }
            }
        });
    }
}
